//
//  PeiDingJiaVC.m
//  JinChengYun
//
//  Created by 金橙云 on 2017/4/17.
//  Copyright © 2017年 金橙云. All rights reserved.
//

#import "PeiDingJiaVC.h"

#import "TodoHttpManager.h"
#import "DouDetailsCell.h"
@interface PeiDingJiaVC ()<UITableViewDataSource,UITableViewDelegate>

{
    NSString *str;
    NSString *str1;
    NSString *str2;
    NSString *str3;
    NSString *str4;

}
@property(nonatomic,strong)NSMutableArray *bigArr;
@property(nonatomic,strong)NSMutableArray *biaoArr;
@property(nonatomic,strong)NSMutableDictionary *dingDic;

@property(nonatomic,strong)UITableView *tabView;

@end

@implementation PeiDingJiaVC

-(void)viewWillAppear:(BOOL)animated
{
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didTDCeoMeBusPeiDingJ:) name:TDCeoMeBusPeiDingJ object:nil];
    
    [_manager userCeoBUsPeiDingJSMWithID:_IDStr];
}
-(void)didTDCeoMeBusPeiDingJ:(NSNotification *)notifi
{
    if (notifi.object != 0)
    {
        _dingDic = [notifi.object objectForKey:@"data"];
        
        str = [_dingDic objectForKey:@"count"];
        str1 = [_dingDic objectForKey:@"area"];
        str2 = [_dingDic objectForKey:@"zongjia"];
        
        str4 = [_dingDic objectForKey:@"djsm"];
        
        
        if ([_conTitle isEqualToString:@"储藏室"])
        {
             _biaoArr = [[NSMutableArray alloc] initWithObjects:str,str1,str2,str4, nil];
        }
        else
        {
             _biaoArr = [[NSMutableArray alloc] initWithObjects:str,str2,str4, nil];
        }
     
        
        [_tabView reloadData];
        
    }
}
-(void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:TDCeoMeBusPeiDingJ object:nil];
}




- (void)viewDidLoad {
    [super viewDidLoad];
   self.title = @"定价说明";
    
    _manager = [TodoHttpManager sharedManager];
    
    _biaoArr = [NSMutableArray array];
    if ([_conTitle isEqualToString:@"储藏室"])
    {
        _bigArr = [NSMutableArray arrayWithObjects:@"储藏室间数:",@"储藏室面积:",@"表价总价:",@"定价说明:", nil];
    }
    else
    {
        _bigArr = [NSMutableArray arrayWithObjects:@"车位间数:",@"表价总价:",@"定价说明:", nil];
    }
   
    _dingDic = [NSMutableDictionary dictionary];
    _tabView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, B_WIDTH, B_HEIGHT) style:UITableViewStylePlain];
    _tabView.delegate = self;
    _tabView.dataSource = self;
    _tabView.backgroundColor = BgColor;
    _tabView.rowHeight = 44;
    _tabView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
    [self.view addSubview:_tabView];

}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    
    
    return _bigArr.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIndent = @"CellB";
    
    
    DouDetailsCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    if (cell ==nil)
    {
        cell = [[DouDetailsCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIndent];
        
        
    }
    
    if ([cell isKindOfClass:[DouDetailsCell class]])
    {
        if (_biaoArr.count !=0)
        {
            
            NSString *str0 = (NSString *)_biaoArr[indexPath.row];
            cell.secondLab.text = [NSString stringWithFormat:@"%@",str0];
            
            
        }
        
        
    }
    
    cell.firstLab.text = _bigArr[indexPath.row];
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//取消点击
    return cell;
    
    
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
